<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/jQery.js"></script>
    <script src="./js/ajax.js"></script>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .head{
            height: 100px;
            background-color: #ccc;
        }
        .wrapper{
            padding: 0 100px;
            margin: 0 auto;
        }
        .head .wrapper{
            display: flex;
            justify-content: space-between;
            padding-top: 30px;
        }
        .head button{
            width: 60px;
            height: 30px;
        }
        .box{
            display: flex;
            justify-content: space-between;
            position: relative;
        }
        .left{
            width: 20%;
            height: 600px;
            background-color: #666;
        }
        .right{
            width: 80%;
            height: 600px;
            background-color: #888;
            overflow: auto;
        }
        h3{
            width: 100%;
            background-color: black;
            color: #fff;
            height: 60px;
            line-height: 60px;
            padding-left: 40px;
            cursor: pointer;
        }
        ul ul li{
            width: 100%;
            height: 60px;
            background-color: black;
            color: #fff;
            padding-left: 60px;
            line-height: 60px;
            cursor: pointer;
        }
        .s{
            display: block;
        }
        ul ul{
            display: none;
        }



        .right #tab{
            width: 100%;
            border-collapse: collapse;
        }
        td{
            /* border: 1px solid #000; */
            /* height: 100px; */
            text-align: center;
        }
        td img{
            height: 100px;
        }
        th{
            border: 1px solid #000;
            height: 20px;
        }
        .gl{
            width: 230px;
        }
        .xia{
            height: 50px;
        }
        tr{
            height: 120px;
        }
        tr button{
            width: 60px;
            height: 30px;
            margin: 10px;
        }
        .sou{
            display: none;
        }
        .right input{
            width: 350px;
            height: 40px;
            border: none;
            outline: none;
            padding-left: 20px;
        }
        .right div button{
            width: 60px;
            height: 40px;
        }
        .right>div{
            display: none;
            position: relative;
        }
        .right .xin{
            display: block;
        }
        .souu{
            display: none;
        }
        #ta li{
            height: 60px;
        }
        #ta a{
            display: inline-block;
            width: 600px;
        }
        #ta div{
            display: inline-block;
            width: 60px;
            height: 30px;
            background-color: rgb(28, 28, 28);
            border-radius: 15px;
            color: #ccc;
            text-align: center;
            line-height: 30px;
            cursor: pointer;
        }
        .vvv{
            position: absolute;
            width: 560px;
            height: 400px;
            background-color: #fff;
            left: 50%;
            top: 20%;
            transform: translate(-20%);
            text-align: center;
            display: none;
        }
        .vvv input{
            margin-top: 30px;
            margin-bottom: 20px;
            width: 480px;
            height: 40px;
        }
        .vvv button{
            display: block;
            width: 60px;
            height: 30px;
            margin-left: 80%;
            margin-top: 30px;
        }
        .vvv textarea{
            display: block;
            width: 500px;
            height: 200px;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <div class="head">
        <div class="wrapper">
            <h2>普通公司</h2>
            <button id="outbtn">退出</button>
        </div>
    </div>
    <div class="box">
        <div class="left">
            <ul id="nav">
                <li>
                    <h3>员工信息</h3>
                    <ul class="s">
                        <li class="cha">查询员工</li>
                        <li class="jia">添加员工</li>
                    </ul>
                </li>
                <li>
                    <h3>新闻</h3>
                    <ul>
                        <li class="see">查询新闻</li>
                        <li class="add">添加新闻</li>
                    </ul>
                </li>
            </ul>
        </div>
        <div class="right">
            <div class="xin">
                <div class="sou"><input class="te" type="text"><button class="so">搜索</button></div>
                <table id="tab">
                    <tr class="xia">
                        <th>编号</th>
                        <th>姓名</th>
                        <th>入职时间</th>
                        <th>加入时间</th>
                        <th>曾任职</th>
                        <th>新职位</th>
                        <th>星级</th>
                        <th>照片</th>
                        <th class="gl">管理</th>
                    </tr>
                </table>
            </div>
            <div>
                <div class="souu"><input class="tee" type="text"><button class="soo">搜索</button></div>
                <ul id="ta">
                </ul>
            </div>
        </div>
        <div class="vvv">
            <input type="text" class="txw">
            <textarea id="tnr"></textarea>
            <button class="pu">添加</button>
        </div>
    </div>
</body>
<script>
    var m=sessionStorage.zz
    if(!m){
        location.href="./11.html"
    }

    sessionStorage.zz="1"


    document.getElementById("outbtn").onclick=function(){
    location.href="11.html"
    sessionStorage.clear()
    }


    var aee=[]
    var xmlHttp=new XMLHttpRequest();
    xmlHttp.open("post","http://www.qhdlink-student.top/student/coach.php","false");
    xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
    xmlHttp.send("username=zyp&userpwd=123456&userclass=70&type=4");
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState===4 && xmlHttp.status===200){
            var data=xmlHttp.responseText;
            var jdata=JSON.parse(data)
            for(var k in jdata){
                aee.push(jdata[k])
            }
        }
    }

    var bee=[]
    r("http://www.qhdlink-student.top/student/newsa.php",text,"username=zyp&userpwd=123456&userclass=70&type=4","post")
    function text(data){
        for(var key in data){
        bee.push(data[key])
        }

    }

    setTimeout(function(){
        var arr=aee.concat()
        var a=location.search.slice(1)

    function tab(){
        var tb=document.getElementById("tab")
        for(var i=0;i<arr.length;i++){
            var tr=document.createElement('tr');
            tb.appendChild(tr);
            for(var k in arr[i]){
                var td=document.createElement('td')
                if(k=="path_coach"){
                    td.innerHTML="<img src='http://www.qhdlink-student.top/"+arr[i][k]+"'>";
                }else{
                    td.innerHTML=arr[i][k];
                }
                tr.appendChild(td);
            }
            var td=document.createElement('td')
            tr.appendChild(td);
            td.innerHTML='<button class="kan">查看</button><button class="shan">删除</button>'
        }
    }

    


        
        if(a==true){
            var lo=localStorage.age
            arr=JSON.parse(lo)
            tab()
            $('.shan').click(function(){
                $(this).parent().parent().remove()
                var gg=$(this).parent().siblings()
                var tt=[]
                for(var i=0;i<gg.length;i++){
                    tt.push(gg[i].innerHTML)
                }

                var aee=[]
                for(var q in arr){
                    var sss=arr[q].id_coach     
                    aee.push(sss)           
                }
                for(var j in aee){
                    if(aee[j]==tt[0]){
                        arr.splice(j,1)
                    }
                }
                var ra=JSON.stringify(arr)
                localStorage.age=ra
                
            })



            var ra=JSON.stringify(arr)
            sessionStorage.dat=ra
        }else{
            tab()
            $('.shan').click(function(){
                $(this).parent().parent().remove()
                var gg=$(this).parent().siblings()
                var tt=[]
                for(var i=0;i<gg.length;i++){
                    tt.push(gg[i].innerHTML)
                }

                var aee=[]
                for(var q in arr){
                    var sss=arr[q].id_coach     
                    aee.push(sss)           
                }
                for(var j in aee){
                    if(aee[j]==tt[0]){
                        arr.splice(j,1)
                    }
                }
                var ra=JSON.stringify(arr)
                localStorage.age=ra
            })
            var ra=JSON.stringify(arr)
            sessionStorage.dat=ra
            

        }


        var as=sessionStorage.ab
        console.log(as)
        var be=bee.slice(0)
        var ok=-1
        var okk=[]
        var con=[]
        $(".pu").click(function(){
            ok++
            var h=document.getElementsByClassName("txw")[0].value
            var obb={
                title_news:h,
                id_news:ok
            }
            var ook=[]
            ook.push(obb)
            for(var key in ook){
                var li=document.createElement("li")
                li.innerHTML="<a class='aa' href='66.html?x"+ok+""+ook[key].id_news+"'>"+ook[key].title_news+"</a><div class='shann'>删除</div>"
                document.getElementById("ta").appendChild(li)
            }
            okk.push(ook)

            var co=$("#tnr").val()

            con.push(co)
            


            var kkk=JSON.stringify(con)
            sessionStorage.xinwen=kkk

            var nk=JSON.stringify(okk)
            sessionStorage.xin=nk
            
            sessionStorage.xn=ok


            $(".vvv").css("display","none")


            $('.shann').click(function(){
                $(this).parent().css("display","none")
            })

        })




        //   表格2
        if(as==undefined){
            for(var key in be){
            var li=document.createElement("li")
            li.innerHTML="<a class='aa' href='66.html?"+be[key].id_news+"'>"+be[key].title_news+"</a><div class='shann'>删除</div>"
            document.getElementById("ta").appendChild(li)
            }
        }else{
            for(var key in be){
            var li=document.createElement("li")
            li.innerHTML="<a class='aa' href='66.html?"+be[key].id_news+"'>"+be[key].title_news+"</a><div class='shann'>删除</div>"
            document.getElementById("ta").appendChild(li)
            }
            var s=sessionStorage.xin
            var zs=JSON.parse(s)
            console.log(zs)
            for(var key in zs){
            var li=document.createElement("li")
            li.innerHTML="<a class='aa' href='66.html?x"+ok+"'>"+zs[key][0].title_news+"</a><div class='shann'>删除</div>"
            document.getElementById("ta").appendChild(li)
            }
        }




        $(document).ready(function(){
            // $("#ta").on("click","li",function(){
            //     sd=$(this).index()
            //     location.href="66.html?"+sd+""
            // })




            $('.shann').click(function(){
                $(this).parent().css("display","none")
                var gg=$(this).parent().siblings()
                var tt=[]
                for(var i=0;i<gg.length;i++){
                    tt.push(gg[i].innerHTML)
                }

                var aee=[]
                for(var q in arr){
                    var sss=arr[q].id_coach     
                    aee.push(sss)           
                }
                for(var j in aee){
                    if(aee[j]==tt[0]){
                        arr.splice(j,1)
                    }
                }
            })


            $('.kan').click(function(){
                var gg=$(this).parent().siblings()
                var tt=[]
                for(var i=0;i<gg.length;i++){
                    tt.push(gg[i].innerHTML)
                }
                a=JSON.stringify(arr)
                console.log(a)
                sessionStorage.data=""+a+""

                var aee=[]
                for(var q in arr){
                    var sss=arr[q].id_coach     
                    aee.push(sss)           
                }
                for(var j in aee){
                    console.log(aee[j])
                    if(aee[j]==tt[0]){
                    location.href="33.html?"+j+""
                    }
                }
            })
        })

        
        $('.so').click(function(){
            var ss=document.getElementsByClassName("te")[0].value
            var aee=[]
            for(var q in arr){
                var sss=arr[q].name_coach
                aee.push(sss)           
            }
            console.log(arr)
            for(var j in aee){
                if(aee[j]==ss){
                    location.href="44.html?"+j+""
                }
            }
        })

        $('.soo').click(function(){
            var ss=document.getElementsByClassName("tee")[0].value
            if(!ss){
                $("#ta").children().css("display","block")
            }else{
                var aee=[]
                var aa=document.getElementsByClassName('aa')
                for(var k in aa){
                    aee.push(aa[k].innerHTML)
                }
                for(var i=0;i<aee.length-3;i++){
                    if(aee[i].indexOf(ss)==-1){
                        $("#ta").children().eq(i).css("display","none")
                    }
                }
            }
        })



        $("h3").click(function(){
            $(this).next().show().parent().siblings().children("ul").hide()
            $(".right").children().eq($(this).parent().index()).css("display","block").siblings().css("display","none")
        })
        $('.cha').click(function(){
            $('.sou').css('display','block')
        })
        $('.jia').click(function(){
            location.href="./55.html"
            a=JSON.stringify(arr)
            sessionStorage.data=""+a+""
        })

        $(".see").click(function(){
            $(".souu").css("display","block")
        })

        $(".add").click(function(){
            $(".vvv").css("display","block")
        })
    },500)



    




</script>
</html>